package com.quarkus.system;

import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import org.jboss.resteasy.annotations.ResponseObject;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Destroyed;
import javax.enterprise.event.Observes;

/**
 * @Author: TongRui乀
 * @Date: 2021/6/5 9:25
 * @description： 测试Java 和 Quarkus 如何进行优雅停机
 */
@ApplicationScoped
public class CustomerShutDownProcessor {

    public void init(@Observes StartupEvent startupEvent){

        System.out.println("start ......");

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            System.out.println("shutdown hook");
        }));
    }


    public void shutdown(@Observes ShutdownEvent shutdownEvent){
        System.out.println("shutdown event");
    }


}
